#!/usr/bin/env python

import sqlalchemy.orm as sao
import sqlalchemy.ext.declarative as sad

from _base import Base

maker = sao.sessionmaker(autoflush=True, autocommit=False)
DbSession = sao.scoped_session(maker)

DeclarativeBase = sad.declarative_base(cls=Base)
metadata = DeclarativeBase.metadata


def init(engine):
    """
    Initialize database session. Call me before using any of the tables or
    classes in the model.
    """

    DbSession.configure(bind=engine)

# remember to define __all__ in each module

from _image import Image
from _image_host import ImageHost
from _image_tag import ImageTag
from _search import Search
from _search_host import SearchHost
from _host import Host
from _tag import Tag
from _post import Post
